/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package network.szyfrowanie;

import java.security.InvalidKeyException;
import java.security.PublicKey;
import java.util.logging.Level;
import java.util.logging.Logger;
import sun.security.rsa.RSAPublicKeyImpl;

/**
 *
 * @author mikolaj
 */
public class Klucze {
    private final String sesja;
    private final  byte[] pub;
    private final byte[] zasz;
    private final byte[] podpis;

    public Klucze(){
        sesja=null;
        this.podpis=null;
        pub=null;
        zasz=null;
    }
    
    public Klucze(PublicKey k,byte[] b, String ses,byte[] podpis){
        pub=k.getEncoded();
        zasz=b;
        sesja=ses;
        this.podpis=podpis;
    }
    
    public Klucze(String ses,byte[] b ){
        sesja=ses;
        zasz=b;
        pub=null;
        podpis=null;
    }
    
    public String getSesja(){
        return sesja;
    }
    public PublicKey getPublic(){
        try {
            return new RSAPublicKeyImpl(pub);
        } catch (InvalidKeyException ex) {
            Logger.getLogger(Klucze.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
    public byte[] getKlucz(){
        byte[] r=new byte[zasz.length];
        System.arraycopy(zasz, 0, r, 0, zasz.length);
        return r;
    }
    public byte[] getPodpis(){
        return podpis;
    }
    
   
    
}
